local zhuifeng = fk.CreateSkill {
  name = "kq__zhuifeng",
}

Fk:loadTranslationTable{
  ["kq__zhuifeng"] = "追锋",
  [":kq__zhuifeng"] = "结束阶段，你可以判定，若结果：为方块，你视为使用一张无距离限制的火【杀】，然后你可以重复此流程；不为方块你获得此判定牌。",

  ["$kq__zhuifeng1"] = "",
  ["$kq__zhuifeng2"] = "",
}

zhuifeng:addEffect(fk.EventPhaseStart, {
  prompt = "进行一次判定",
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(zhuifeng.name) and player.phase == Player.Finish
  end,
  on_use = function(self, event, target, player, data)
    while not player.dead do
        local judge = {
        who = player,
        reason = zhuifeng.name,
        pattern = ".|.|diamond",
        }
        player.room:judge(judge)
        if  judge.card.suit == Card.Diamond then
            if  player.room:askToSkillInvoke(player, {
            skill_name = zhuifeng.name,
            prompt = "重复此流程",
            })
            then
                player.room:delay(1)
            else
                break
            end
        else
            break
        end
    end
  end,
})

zhuifeng:addEffect(fk.FinishJudge, {
  is_delay_effect = true,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and data.reason == zhuifeng.name and
    data.card.suit ~= Card.Diamond and player.room:getCardArea(data.card.id) == Card.Processing
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player.room:obtainCard(player, data.card, true, nil, player, zhuifeng.name)
  end,
})

zhuifeng:addEffect(fk.FinishJudge, {
  is_delay_effect = true,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and data.reason == zhuifeng.name and
    data.card.suit == Card.Diamond and player.room:getCardArea(data.card.id) == Card.Processing
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room.alive_players, function(p)
        local slash = Fk:cloneCard("slash")
        return  not (player:isProhibited(p, slash) or player:prohibitUse(slash))
    end)
    local to = room:askToChoosePlayers(player, {
        targets = targets,
        min_num = 1,
        max_num = 1,
        prompt = "视为对其使用一张火【杀】",
        skill_name = zhuifeng.name,
    })
    if #to > 0 then
       room:useVirtualCard("fire__slash", nil, player, to, zhuifeng.name) 
    end
  end,
})

return zhuifeng
